#ifndef UPDATETHREAD_H
#define UPDATETHREAD_H

#include <QThread>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QBuffer>
#include <QUrl>
#include "http.h"
#include "parser.h"
#include "updatethreadtimer.h"

class UpdateThread : public QThread
{
    Q_OBJECT
public:
    explicit UpdateThread(QObject *p_parent = 0, int p_id = 0);
    ~UpdateThread();
    void run();
    void setId(int p_id){id = p_id;}
    void setIntervall(int p_intervall){intervall = p_intervall;}
    void resetTimer();

public slots:
    void writeData(QByteArray array);
    void getLastId(QByteArray array);
    void writeSecondData(QByteArray array);
    void sendSecond();
    void download(int timer);
    void timerSlot();

signals:
    void dataReceived(QByteArray);
    void emitDownload(int);

private:
    Http *http;
    Http *second_http;
    QByteArray bytes;
    QUrl url;
    int id;
    bool isDownloaded;
    int intervall;
    QObject* parent;
    UpdateThreadTimer timer;
    QList<int> *ignoreList;
    int currentTimerId;

};

#endif // UPDATETHREAD_H
